# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  # Pick a unique cookie name to distinguish our session data from others'
  session :session_key => '_metasland_session_id'
  
  def authorize
    unless session[:user_id]
      flash[:notice] = "没有登录！"
      redirect_to :controller => "login", :action => "index"
    end
  end
  
  def grade
    gd = User.find(session[:user_id]).role.encoding
    unless gd == 'sa' || gd =='na'
      flash[:notice] = "您无权访问该模块！"
      redirect_to :controller => "land", :action => "index"
    end
  end
  
  def topright
    unless User.find(session[:user_id]).role.encoding == 'sa'
      flash[:notice] = "您无权访问该模块！"
      redirect_to :controller => "land", :action => "index"
    end
  end
end
